Skip to content

Conversation

@2PykeETH
Copy link

@2PykeETH 2PykeETH commented Oct 1, 2025

Summary

This PR introduces the removeLiquidity external function to the TestAMMContract with full NatSpec annotations. The function allows users to withdraw liquidity from prediction market pools while ensuring proportional distribution of reserves and protection against slippage.


Changes

  • New Function: removeLiquidity

    • Parameters:
      • _marketId — unique identifier for the prediction market.
      • _user — address of the liquidity provider removing funds.
      • _liquidity — amount of liquidity tokens to burn/remove.
      • _amount0Min — minimum acceptable amount of tokenA (slippage protection).
      • _amount1Min — minimum acceptable amount of tokenB (slippage protection).
    • Returns:
      • amount0Decreased — tokenA returned to user.
      • amount1Decreased — tokenB returned to user.
      • amount0Collected — mirrors amount0Decreased (simplified model).
      • amount1Collected — mirrors amount1Decreased (simplified model).
  • NatSpec Documentation:

    • Detailed descriptions for purpose, effects, requirements, and edge cases.
    • Added custom tags:
      • @custom:proportional — clarifies liquidity share math.
      • @custom:slippage — explains role of slippage protection.
  • Formatting:

    • Applied forge fmt for consistency and readability.

Motivation

  • Completeness: Provides a full liquidity cycle by complementing existing addLiquidity functionality.
  • Safety: Introduces slippage protection and reserve checks to protect users from unexpected losses.
  • Transparency: Rich NatSpec comments improve maintainability, audits, and developer onboarding.

Next Steps

  • Implement internal accounting updates for userLiquidity mapping (if not already included).
  • Ensure LiquidityRemoved event emission with full context (user, marketId, amounts).
  • Add unit/integration tests covering:
    • Successful proportional liquidity removal.
    • Failure when reserves are insufficient.
    • Failure when user liquidity < requested amount.
    • Edge cases for minimum slippage thresholds.

@Neros0 Neros0 self-requested a review October 1, 2025 18:57
@Neros0 Neros0 added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 1, 2025
@Neros0 Neros0 merged commit 233dc3c into Arenium-Social:main Oct 1, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants